package cn.minimal;

public class Tank {
    int x = 0;
    int y = 0;
    int type = 0; // 0 - 我方坦克，1 - 敌方坦克
    int direction = 0; // 0 - 方向向上，1 - 方向向右，2 - 方向向下，3 - 方向向左
    int speed = 3;
    Shot shot = null;
    Bomb bomb = null;
    boolean isLive = true;
    int bomb_time = 3;
    int revive_time = 5;
    public int getSpeed() {
        return speed;
    }
    public void setSpeed(int speed) {
        this.speed = speed;
    }
    public Tank(int x, int y, int type, int direction) {
       this.x = x;
       this.y = y;
       this.type = type;
       this.direction = direction;
    }
    public int getX() {
        return x;
    }
    public void setX(int x) {
        this.x = x;
    }
    public int getY() {
        return y;
    }
    public void setY(int y) {
        this.y = y;
    }
    public int getType() {
        return type;
    }
    public void setType(int type) {
        this.type = type;
    }
    public int getDirection() {
        return direction;
    }
    public void setDirection(int direction) {
        this.direction = direction;
    }
    public Shot getShot() {
        return shot;
    }
    public void setShot(Shot shot) {
        this.shot = shot;
    }
    public void showShot() {
        Shot shot = new Shot(x, y, direction);
        setShot(shot);
        Thread t = new Thread(this.shot);
        t.start();
    }
    public void moveLeft() {
        setDirection(3);
        setX(x - speed);
    }
    public void moveRight() {
        setDirection(1);
        setX(x + speed);
    }
    public void moveUp() {
        setDirection(0);
        setY(y - speed);
    }
    public void moveDown() {
        setDirection(2);
        setY(y + speed);
    }
}
